<%@ page contentType="text/html;charset=UTF-8" language="java"%>
<%@ page import="java.util.List"%>
<%@ page import="java.util.LinkedList"%>
<%@ page import="com.google.appengine.api.users.User"%>
<%@ page import="com.google.appengine.api.users.UserService"%>
<%@ page import="com.google.appengine.api.users.UserServiceFactory"%>
<%@ page import="com.google.appengine.api.datastore.DatastoreServiceFactory"%>
<%@ page import="com.google.appengine.api.datastore.DatastoreService"%>
<%@ page import="com.google.appengine.api.datastore.Query"%>
<%@ page import="com.google.appengine.api.datastore.Entity"%>
<%@ page import="com.google.appengine.api.datastore.FetchOptions"%>
<%@ page import="com.google.appengine.api.datastore.Key"%>
<%@ page import="com.google.appengine.api.datastore.KeyFactory"%>
<%@ page import="com.google.appengine.api.datastore.Text"%>
<%@ page import="com.google.appengine.api.oauth.OAuthRequestException"%>
<%@ page import="com.google.appengine.api.oauth.OAuthService"%>
<%@ page import="com.google.appengine.api.oauth.OAuthServiceFactory"%>
<%@ page import="com.google.appengine.api.oauth.OAuthServiceFailureException"%>
<%@ page import="com.google.appengine.api.datastore.Query.FilterOperator"%>
<%@ page import="java.util.Date"%>
<%@ page import="edu.dhbw.mannheim.Admin"%>
<%@ page import="edu.dhbw.mannheim.Post"%>
<!-- list post -->
<%
	// add filter, if it is given
	String filter = (String) request.getParameter("filter");
	String sort = (String) request.getParameter("sort");
	User filterUser = Admin.findUser(filter);
	String filterParam = "";
	if(filter != null) {
		filterParam = "&filter="+filter;
	}
%>
	<div class="small inner round">
	You can sort 
	<a href="blog.jsp?type=listposts&sort=topic<%= filterParam %>">by topic</a> 
	or 
	<a href="blog.jsp?type=listposts&sort=date<%= filterParam %>">by date</a> 
	</div>
	
	<div id='postsList'>
		<%=Post.getPostsAsHTML(0, 10, filterUser, sort)%>
	</div><%
	
%>
